from django import forms
from django.core.exceptions import ValidationError


def words_validator(message):
    if len(message) < 4:
        raise ValidationError('Not enough words!')


def comment_validator(comment):
    if 'fuck' in comment or 'shit' in comment:
        raise ValidationError('Do not use that word!')


# class CommentForm(forms.Form):
#     name = forms.CharField(max_length=50, widget=forms.TextInput(attrs={'class': 'form-control'}))
#     comment = forms.CharField(
#         widget=forms.Textarea(attrs={'class': 'form-control'}),
#         error_messages={
#             'required': 'such words'
#         },
#         validators=[words_validator, comment_validator]
#     )


class IssueForm(forms.Form):
    title = forms.CharField(max_length=128)
    description = forms.CharField(required=False)
    anonymity = forms.BooleanField(required=False)


class AnswerForm(forms.Form):
    # issue = forms.CharField(max_length=128)
    answer = forms.CharField(strip=False)
    anonymity = forms.BooleanField(required=False)


class CommentForm(forms.Form):
    comment = forms.CharField(min_length=6)
